<template>
    <view class="container">
        <NavBar title="材料入库" @back="goBack" />
        <scroll-view scroll-y class="list">
			<uv-empty mode="data" text="暂无数据" v-if="formList.length==0" ></uv-empty>
            <view class="list-item" v-for="item in formList" :key="item.id">

                <view class="item-content">
                    <text class="text-left">编码</text>
                    <text class="text-right">{{ item.code }}</text>
                </view>
                <view class="item-content">
                    <text class="text-left">名称</text>
                    <text class="text-right">{{ item.name }}</text>
                </view>
                <view class="item-content">
                    <text class="text-left">规格</text>
                    <text class="text-right">{{ item.specs }}</text>
                </view>
                <view class="item-content">
                    <text class="text-left">数量</text>
                    <text class="text-right">{{ item.num }}</text>
                </view>
                <view class="item-content">
                    <text class="text-left">单价</text>
                    <text class="text-right">{{ item.unitPrice }}</text>
                </view>
                <view class="item-content">
                    <text class="text-left">材质单编号</text>
                    <text class="text-right">{{ item.czdCode }}</text>
                </view>
                <view class="item-content">
                    <text class="text-left">批次或炉号</text>
                    <text class="text-right">{{ item.batchRemark }}</text>
                </view>
            </view>
        </scroll-view>
    </view>
</template>

<script>
import NavBar from '@/components/NavBar/index.vue'
import {
    getMaterialSingleItem
} from '@/utils/app.js'
export default {
    components: { NavBar },
    data() {
        return {
            formList: []
        };
    },
    onLoad(options) {
        console.log(options, 99);
        if (options.data) {
            const parsedData = JSON.parse(decodeURIComponent(options.data));
            this.getMaterialSingleData(parsedData)
        }
    },
    methods: {
        onPullDownRefresh() {
            this.getMaterialSingleData()
        },
        goBack() {
            uni.navigateBack({
                delta: 1
            })
        },
        getMaterialSingleData(data) {
			uni.showLoading({
				title: "加载中",
				mask: true
			});
            getMaterialSingleItem({
                materialSingleId: data.id || data,
            }).then(res => {
				uni.hideLoading();
                if (res && res.code == 200) {
                    this.formList = res.rows
                }
            })
			
        }
    }
}
</script>

<style lang="scss" scoped>
* {
    box-sizing: border-box;
}

.container {
    background-color: #E6EAF3;
}

.list {
    height: 1450rpx;
    background-color: #fff;
    background-color: #E6EAF3;

    .list-item {
        margin: 20rpx auto 0;
        padding: 48rpx 24rpx 16rpx;
        width: 700rpx;
        background-color: #fff;
        border-radius: 32rpx;
    }

    .item-content {
        height: 48rpx;
        line-height: 48rpx;
        font-size: 24rpx;
        color: #72767C;
    }

    .text-left {
        margin-right: 16rpx;
        width: 180rpx;
        display: inline-block;
		font-size: 30rpx;
    }

    .text-right {
        margin-left: 16rpx;
		font-size: 30rpx
    }
}
</style>
